// 增强编程式路由导航push,replace方法
import VueRouter from 'vue-router'

const methods = ['push', 'replace']

methods.forEach(item => {
  const overwrite = VueRouter.prototype[item]
  VueRouter.prototype[item] = function (path, successful, error) {
    if (successful || error) {
      overwrite.call(this, path, successful, error)
    } else {
      overwrite.call(this, path).catch(() => {
      })
    }
  }
})
